<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      lang="en">
    <h:head>
        <o:resourceInclude path="/CustomizationFilesServlet?customFileType=analytics" />
        <title><h:outputText value="#{pageTitle}"/></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta http-equiv="Content-Language" content="en"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <link rel="apple-touch-icon" sizes="180x180" href="#{resource['images/fav/apple-touch-icon.png']}"/>
        <link rel="icon" type="image/png" sizes="32x32" href="#{resource['images/fav/favicon-32x32.png']}"/>
        <link rel="icon" type="image/png" sizes="16x16" href="#{resource['images/fav/favicon-16x16.png']}"/>
        <link rel="manifest" href="#{resource['images/fav/site.webmanifest']}"/>
        <link rel="mask-icon" href="#{resource['images/fav/safari-pinned-tab.svg']}" color="#da532c"/>
        <meta name="msapplication-TileColor" content="#da532c"/>
        <meta name="theme-color" content="#ffffff"/>
        <link type="image/png" rel="image_src" href="#{resource['images/dataverseproject.png']}" />
        <link type="text/css" rel="stylesheet" href="#{resource['bs/css/bootstrap.min.css']}?version=#{systemConfig.getVersion()}" />
        <link type="text/css" rel="stylesheet" href="#{resource['bs/css/bootstrap-theme.min.css']}?version=#{systemConfig.getVersion()}" />
        <link type="text/css" rel="stylesheet" href="#{resource['css/ie-compat.css']}?version=#{systemConfig.getVersion()}" />
        <link type="text/css" rel="stylesheet" href="#{resource['css/fontcustom.css']}?version=#{systemConfig.getVersion()}" />
        <link type="text/css" rel="stylesheet" href="#{resource['css/socicon.css']}?version=#{systemConfig.getVersion()}" />
        <link type="text/css" rel="stylesheet" href="#{resource['css/structure.css']}?version=#{systemConfig.getVersion()}" />
        
        <script>
            //<![CDATA[
            var pageSource = window.location.href;
            var params = parseQueryString(pageSource.split('?')[1]);
            params.alias; // widgetScope
            params.persistentId; // persistentId
            
            function parseQueryString(queryString) {
                var params = {};
                var pl     = /\+/g;
                if (queryString) {
                    var keyValues = queryString.split('&');
                    for (var i=0; i < keyValues.length; i++) {
                        var pair = keyValues[i].split('=');
                        params[pair[0]] = pair[1].replace(pl, " ");
                    }
                }
                return params;
            }
            
            var forwardSource = "/dataset.xhtml?persistentId=" + params.persistentId;

            // Don't allow to load outside of iframe
            if (self === top) {
                top.location = forwardSource;
            }
            //]]>
        </script>
    </h:head>
    <h:body>
        <f:loadBundle basename="propertyFiles.Bundle" var="bundle"/>
        <f:metadata>
            <f:viewParam name="persistentId" value="#{DatasetPage.persistentId}"/>
            <f:viewAction action="#{DatasetPage.initCitation}" rendered="true"/>
        </f:metadata>
        <div class="container">
            <h:form id="iframeForm">
                <!-- DATASET CITATION BLOCK -->
                <ui:include src="dataset-citation.xhtml" />
            </h:form>
        </div>
        <!-- FOOTER BLOCK -->
        <ui:include src="dataverse_footer.xhtml">
            <ui:param name="widgetView" value="true"/>
            <ui:param name="loginRedirectPage" value="#{loginRedirectPage != null ? '?redirectPage='.concat(loginRedirectPage) : navigationWrapper.redirectPage}"/>
        </ui:include>

        <p:ajaxStatus id="ajaxStatusPanel">
            <f:facet name="start">
                <h:graphicImage value="/resources/images/ajax-loading.gif" alt="#{bundle['loading']}" />
            </f:facet>
            <f:facet name="complete">
                <!-- DO NOTHING -->
            </f:facet>
        </p:ajaxStatus>
        <script defer="defer" src="#{resource['bs/js/bootstrap.min.js']}?version=#{systemConfig.getVersion()}"></script>
        <script defer="defer" src="#{resource['js/dv_rebind_bootstrap_ui.js']}?version=#{systemConfig.getVersion()}"></script>
    </h:body>
</html>
